using UnityEngine;
using System.Collections;

public class Leaves : MonoBehaviour {
    private float[] particleSpeed = new float[5000];
    private float[] particleSpeedX = new float[5000];
    private float[] particleAim = new float[5000];
    private float[] particleSpeedRandom = new float[5000];
    private float[] particleSinRandom = new float[5000];
	// Use this for initialization
    public float ySpeed;
    public float xSpeed;
    public float regularXSpeed;
    public float regularYSpeed;
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
        var particles = particleEmitter.particles;
	    for (int n=0;n<particles.Length;n++)
        {
            if (particleSpeedRandom[n] == 0f)
            {
                particleSpeedRandom[n] = Random.Range(0, 500);
                particleSinRandom[n] = Random.Range(1f, 2f);
            }
            particleSpeed[n] = Mathf.Sin(particles[n].position.x/particleSinRandom[n] - particleSpeedRandom[n]) * ySpeed;
            particleSpeedX[n] = Mathf.Sin(particles[n].position.y/2.6f-particleSpeedRandom[n]) * xSpeed;
            particles[n].position += new Vector3(particleSpeedX[n],particleSpeed[n],0);
            //particles[n].position += new Vector3(regularXSpeed,regularYSpeed, 0);
        }
        gameObject.particleEmitter.particles = particles;
	}
}
